package com.jeasonzhao.report.dataset;

import java.io.Serializable;

public class PageInfo implements Serializable
{
    private static final long serialVersionUID = 1L;
    private int m_nCurrentPageNo = 0;
    private int m_nPageSize = 0;
    private int m_nPagesCount = 0;
    private int m_nRowsCount = 0;
    private int m_nAbsoluteBeginRowIndex = 0;
    private int m_nFilteredRows = -1;
    public PageInfo(int nNo,int nSize,int nRowsCount,int nRowBeginIndex)
    {
        m_nCurrentPageNo = Math.max(0,nNo);
        m_nPageSize = nSize;
        m_nAbsoluteBeginRowIndex = nRowBeginIndex;
        setRowsCount(nRowsCount);
    }

    public int getFilteredRowsCount()
    {
        return m_nFilteredRows;
    }

    public void setFilteredRowsCount(int n)
    {
        m_nFilteredRows = n;
    }

    public int getPageCount()
    {
        return m_nPagesCount;
    }

    public int getAbsoluteBeginRowIndex()
    {
        return m_nAbsoluteBeginRowIndex;
    }

    public int getPageNo()
    {
        return m_nCurrentPageNo;
    }

    public int getPageSize()
    {
        return m_nPageSize;
    }

    public int getRowsCount()
    {
        return m_nRowsCount;
    }

    private void setRowsCount(int RowsCounts)
    {
        this.m_nRowsCount = RowsCounts;
        this.m_nPagesCount = this.m_nPageSize <= 0 ? 0 :
            ((int) (RowsCounts / m_nPageSize) + ((RowsCounts % m_nPageSize) > 0 ? 1 : 0));
    }
}
